<template>
  <div class="friendshipLinkPage">
    <div class="linkList">
      <div class="title">友情链接</div>
      <div class="item" @click="select(it)" v-for="(it, index) in linkList.slice(0, 5)" :key="index">
        {{it.name}}
        <span class="sz_arrows_right"></span>
      </div>
    </div>
    <div class="itemList">
      <div v-for="(it, index) in itemList" :key="index" @click="goTo(it.url)" class="item">{{ it.lname }}</div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      linkList: [
      ],
      itemList: []
    };
  },
  mounted() {
    this.getFriendshipLinkData();
  },
  methods: {
    // 获取友情链接数据
    getFriendshipLinkData() {
      this.axios({
        url: "/seeyon/rest/select/friendlyUrl",
        method: "post",
        headers: {
          "Content-Type": "application/json",
          "token":localStorage.getItem("restToken"),
        },
        data: {
          loginName: localStorage.getItem("loginName")
        },
      }).then((res) => {
        console.log("获取友情链接数据", res);
        this.linkList = res.data.data.friendlyUrlList;
        // this.itemList = this.linkList[0].menus
        console.log("this.linkList", this.linkList);
      });
    },
    goTo(url){
      window.open(url,'_blank')
    },
    select(it){
      this.itemList = it.menus
    }
  },
};
</script>
<style lang="less" scoped>
.friendshipLinkPage {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  // align-items: center;
  .title {
    font-weight: 600;
    font-size: 20px;
    line-height: 40px;
    min-width: 120px
  }
  .linkList{
    display: flex;
    justify-content: space-around;
    flex: 1;
    .item{
        width: 180px;
        height: 40px;
        line-height: 40px;
        border: 1px solid #ccc;
        padding: 0 10px;
        cursor: pointer;
        position: relative;
        .sz_arrows_right{
            transform: rotate(180);
            display: inline-block;
            transform: rotate(90deg);
            position: absolute;
            top: 12px;
            right: 12px;
        }
    }
  }
  .itemList{
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    .item{
      width: 180px;
      height: 40px;
      line-height: 40px;
      margin-left: 15px;
      margin: 5px 0;
      text-align: center;
      border-radius: 5px;
      cursor: pointer;
    }
  }
}
</style>
